const SearchType = {
    '校园招聘': 'positionList',
    '社会招聘': 'positionList4Society',
    '实习生招聘': 'positionList4Internship'
}
$(document).ready(function () {
    var width = document.documentElement.clientWidth || document.body.clientWidth
    // $(document).mousemove(function(e){
    //     var scrollX = e.pageX
    //     if (scrollX < (width/3)) {
    //         $('.right').removeClass('right_out')
    //         $('.left').addClass('left_out')
    //     } else if (scrollX > (2 * width / 3)) {
    //         $('.right').addClass('right_out')
    //         $('.left').removeClass('left_out')
    //     } else {
    //         $('.left').removeClass('left_out')
    //         $('.right').removeClass('right_out')
    //     }
    // })
    $('.top-select').click(function (event) {
        $('.select ul').slideToggle()
        event.stopPropagation()
    })
    $(document).click(function () {
        $('.select ul').slideUp()
    })
    $('.select ul li').click(function () {
        $('.chosen').html($(this).html())
        $('.select ul').slideToggle()
    })
    $('input').keydown(function(event){
        if (event.keyCode == 13) {
            search()
        }
    })
    $('.search-icon').click(function () {
        search()
    })
    $('.links span').click(function () {
        var type = $('.chosen').html() || '校园招聘'
        var range = SearchType[type]
        var keyword = $(this).html()
        window.location.href = 'http://' + window.location.host + '/pages/' + range + '.html?position=' + encodeURI(keyword)
    })
    function search() {
        var type = $('.chosen').html() || '校园招聘'
        var range = SearchType[type]
        var keyword = $('.search input').val()
        window.location.href = 'http://' + window.location.host + '/pages/' + range + '.html?position=' + encodeURI(keyword)
    }
})